package com.ruoyi.project.system.memberbusiness.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.common.utils.uniquekey.IdGererateFactory;
import com.ruoyi.project.system.memberbusiness.domain.MemberBusiness;
import com.ruoyi.project.system.memberbusiness.mapper.MemberBusinessMapper;
import com.ruoyi.project.system.memberbusiness.service.IMemberBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 用户主营业务Service业务层处理
 * 
 * @author LCL
 * @date 2021-11-04
 */
@Service
public class MemberBusinessServiceImpl implements IMemberBusinessService 
{
    @Autowired
    private MemberBusinessMapper memberBusinessMapper;
    @Resource
    private IdGererateFactory idGererateFactory;

    /**
     * 查询用户主营业务
     * 
     * @param id 用户主营业务ID
     * @return 用户主营业务
     */
    @Override
    public MemberBusiness selectMemberBusinessById(String id)
    {
        return memberBusinessMapper.selectMemberBusinessById(id);
    }

    /**
     * 查询用户主营业务列表
     * 
     * @param memberBusiness 用户主营业务
     * @return 用户主营业务
     */
    @Override
    public List<MemberBusiness> selectMemberBusinessList(MemberBusiness memberBusiness)
    {
        return memberBusinessMapper.selectMemberBusinessList(memberBusiness);
    }

    /**
     * 新增用户主营业务
     * 
     * @param memberBusiness 用户主营业务
     * @return 结果
     */
    @Override
    public int insertMemberBusiness(MemberBusiness memberBusiness)
    {
        memberBusiness.setId(idGererateFactory.nextStringId());
        memberBusiness.setCreatedTime(new Date());
        return memberBusinessMapper.insertMemberBusiness(memberBusiness);
    }

    /**
     * 修改用户主营业务
     * 
     * @param memberBusiness 用户主营业务
     * @return 结果
     */
    @Override
    public int updateMemberBusiness(MemberBusiness memberBusiness)
    {
        memberBusiness.setUpdatedTime(new Date());
        return memberBusinessMapper.updateMemberBusiness(memberBusiness);
    }

    /**
     * 删除用户主营业务对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMemberBusinessByIds(String ids)
    {
        return memberBusinessMapper.deleteMemberBusinessByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户主营业务信息
     * 
     * @param id 用户主营业务ID
     * @return 结果
     */
    @Override
    public int deleteMemberBusinessById(String id)
    {
        return memberBusinessMapper.deleteMemberBusinessById(id);
    }
}
